<!DOCTYPE html>
<html lang="zh-Hans">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.3.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/blog/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/blog/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/blog/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/blog/images/logo.svg" color="#222">

<link rel="stylesheet" href="/blog/css/main.css">

<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&display=swap&subset=latin,latin-ext">
<link rel="stylesheet" href="/blog/lib/font-awesome/css/font-awesome.min.css">


<script id="hexo-configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    hostname: new URL('https://guodh.gitee.io/blog').hostname,
    root: '/blog/',
    scheme: 'Pisces',
    version: '7.7.1',
    exturl: false,
    sidebar: {"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},
    copycode: {"enable":true,"show_result":true,"style":null},
    back2top: {"enable":true,"sidebar":false,"scrollpercent":false},
    bookmark: {"enable":false,"color":"#222","save":"auto"},
    fancybox: false,
    mediumzoom: false,
    lazyload: false,
    pangu: false,
    comments: {"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},
    algolia: {
      appID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    },
    localsearch: {"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
    path: 'search.xml',
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}
  };
</script>

  <meta name="description" content="很久以前就看到过关于Hbase的相关信息，那时以为这种需要大数据相关知识的数据库肯定是我这种业务开发程序员所接触不到的。但是随着经历的公司多了，发现其实对于大数据这个概念而言，其实不过是Java开发的一个分支。你可以看到在很多的ToB业务中，都需要用到Hive，HBase，Spark等等这类常见的Hadoop系列的大数据操作工具。相对与ToC的业务，ToB需要看到数据的变化，越多的数据对于客户具有">
<meta property="og:type" content="article">
<meta property="og:title" content="Hbase从入门到实践">
<meta property="og:url" content="https://guodh.gitee.io/blog/2018/11/17/2018/Hbase%E4%BB%8E%E5%85%A5%E9%97%A8%E5%88%B0%E5%AE%9E%E8%B7%B5/index.html">
<meta property="og:site_name" content="蛋蛋的小屋">
<meta property="og:description" content="很久以前就看到过关于Hbase的相关信息，那时以为这种需要大数据相关知识的数据库肯定是我这种业务开发程序员所接触不到的。但是随着经历的公司多了，发现其实对于大数据这个概念而言，其实不过是Java开发的一个分支。你可以看到在很多的ToB业务中，都需要用到Hive，HBase，Spark等等这类常见的Hadoop系列的大数据操作工具。相对与ToC的业务，ToB需要看到数据的变化，越多的数据对于客户具有">
<meta property="og:locale">
<meta property="og:image" content="https://guodh.gitee.io/study.png">
<meta property="og:image" content="https://guodh.gitee.io/Hbase.png">
<meta property="og:image" content="https://guodh.gitee.io/index.png">
<meta property="og:image" content="https://guodh.gitee.io/hbaseAll.png">
<meta property="article:published_time" content="2018-11-17T04:53:01.000Z">
<meta property="article:modified_time" content="2018-11-24T07:33:27.000Z">
<meta property="article:author" content="RunningEgg">
<meta property="article:tag" content="Hbase">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://guodh.gitee.io/study.png">

<link rel="canonical" href="https://guodh.gitee.io/blog/2018/11/17/2018/Hbase%E4%BB%8E%E5%85%A5%E9%97%A8%E5%88%B0%E5%AE%9E%E8%B7%B5/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome: false,
    isPost: true
  };
</script>

  <title>Hbase从入门到实践 | 蛋蛋的小屋</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-meta">

    <div>
      <a href="/blog/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">蛋蛋的小屋</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
        <p class="site-subtitle">来了就看看吧，没有刀剑只有故事</p>
  </div>

  <div class="site-nav-toggle">
    <div class="toggle" aria-label="Toggle navigation bar">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/blog/" rel="section"><i class="fa fa-fw fa-home"></i>Home</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/blog/about/" rel="section"><i class="fa fa-fw fa-user"></i>About</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/blog/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>Archives</a>

  </li>
        <li class="menu-item menu-item-book">

    <a href="/blog/book/" rel="section"><i class="fa fa-fw fa-archive"></i>book</a>

  </li>
  </ul>

</nav>
</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content">
            

  <div class="posts-expand">
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block " lang="zh-Hans">
    <link itemprop="mainEntityOfPage" href="https://guodh.gitee.io/blog/2018/11/17/2018/Hbase%E4%BB%8E%E5%85%A5%E9%97%A8%E5%88%B0%E5%AE%9E%E8%B7%B5/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/blog/images/avatar.gif">
      <meta itemprop="name" content="RunningEgg">
      <meta itemprop="description" content="写下我的点点滴滴，写下我对这个世界的看法，还有我内心锁崇拜的技术">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="蛋蛋的小屋">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          Hbase从入门到实践
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">Posted on</span>

              <time title="Created: 2018-11-17 12:53:01" itemprop="dateCreated datePublished" datetime="2018-11-17T12:53:01+08:00">2018-11-17</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">Edited on</span>
                <time title="Modified: 2018-11-24 15:33:27" itemprop="dateModified" datetime="2018-11-24T15:33:27+08:00">2018-11-24</time>
              </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>很久以前就看到过关于Hbase的相关信息，那时以为这种需要大数据相关知识的数据库肯定是我这种业务开发程序员所接触不到的。<br>但是随着经历的公司多了，发现其实对于大数据这个概念而言，其实不过是Java开发的一个分支。你可以看到在很多的ToB业务中，都需要用到Hive，HBase，Spark等等这类常见的Hadoop系列的大数据操作工具。相对与ToC的业务，ToB需要看到数据的变化，越多的数据对于客户具有越高的价值。<br>例如，最近跑Demo的一个用户的店，广告系统就有60W的关键词信息，而且产品还要求每两个小时给用户跑一次。所以对于一般的程序员，大数据相关也是需要知道相关知识的。</p>
<p>有点扯远了，回到Hbase这个话题，这次通过这个项目对于Hbase有了一个完整的理解，所以一起来分析给大家。</p>
<a id="more"></a>

<h2 id="如何学习新的知识"><a href="#如何学习新的知识" class="headerlink" title="如何学习新的知识"></a>如何学习新的知识</h2><p>看了上一期的《奇葩说》，还是很有感触的。知识是无限的，而智慧才是有限的，不断的归纳总结是对知识提升到智慧最好的途径。<br>我总结归纳了一下如何学习一块新软件的系统，这里包括了语言，包块了数据库这类开箱即用的系统。</p>
<img src="/study.png" width="80%" height="80%" alt="如何学习"/>


<h2 id="学会使用"><a href="#学会使用" class="headerlink" title="学会使用"></a>学会使用</h2><img src="/Hbase.png" width="100%" height="150%" alt="Hbase"/>

<p>在Hbase中是没有数据结构的，无论在那一行你都可以放下很长很长的列。这就意味着它很适合做一些数据仓库的业务场景，无须关注数据的结构，拿到数据就往里面扔。唯一需要设计的就是ROWKEY。简单的讲，数据是按照字典序来排放的，当你扫描相邻的数据就会很快。当然，它也是任使用者随意摆放的。</p>
<table>
<thead>
<tr>
<th>ROW KEY</th>
<th>数据内容</th>
</tr>
</thead>
<tbody><tr>
<td>aabb</td>
<td>。。。</td>
</tr>
<tr>
<td>abaa</td>
<td>。。。</td>
</tr>
<tr>
<td>ba</td>
<td>。。。</td>
</tr>
<tr>
<td>bbcc</td>
<td>。。。</td>
</tr>
</tbody></table>
<h3 id="创建Hbase表"><a href="#创建Hbase表" class="headerlink" title="创建Hbase表"></a>创建Hbase表</h3><figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">create</span> <span class="string">&#x27;campaigns&#x27;</span>,</span><br><span class="line">&#123;NAME =&gt;&#x27;campaign&#x27;, VERSIONS =&gt; 1, BLOCKCACHE =&gt; true, BLOCKSIZE =&gt; &#x27;65536&#x27;, BLOOMFILTER =&gt; &#x27;ROW&#x27;&#125;,</span><br><span class="line">&#123;SPLITS =&gt; [&#x27;00&#x27;,&#x27;01&#x27;,&#x27;02&#x27;,&#x27;03&#x27;,&#x27;04&#x27;,&#x27;05&#x27;,&#x27;06&#x27;,&#x27;07&#x27;,&#x27;08&#x27;,&#x27;09&#x27;,&#x27;10&#x27;,&#x27;11&#x27;,&#x27;12&#x27;,&#x27;13&#x27;,&#x27;14&#x27;,&#x27;15&#x27;,&#x27;16&#x27;,&#x27;17&#x27;,</span><br><span class="line"><span class="string">&#x27;18&#x27;</span>,<span class="string">&#x27;19&#x27;</span>,<span class="string">&#x27;20&#x27;</span>,<span class="string">&#x27;21&#x27;</span>,<span class="string">&#x27;22&#x27;</span>,<span class="string">&#x27;23&#x27;</span>,<span class="string">&#x27;24&#x27;</span>,<span class="string">&#x27;25&#x27;</span>,<span class="string">&#x27;26&#x27;</span>,<span class="string">&#x27;27&#x27;</span>,<span class="string">&#x27;28&#x27;</span>,<span class="string">&#x27;29&#x27;</span>,<span class="string">&#x27;30&#x27;</span>,<span class="string">&#x27;31&#x27;</span>,<span class="string">&#x27;32&#x27;</span>,<span class="string">&#x27;33&#x27;</span>,<span class="string">&#x27;34&#x27;</span>,<span class="string">&#x27;35&#x27;</span>,<span class="string">&#x27;36&#x27;</span>,<span class="string">&#x27;37&#x27;</span>,</span><br><span class="line"><span class="string">&#x27;38&#x27;</span>,<span class="string">&#x27;39&#x27;</span>,<span class="string">&#x27;40&#x27;</span>,<span class="string">&#x27;41&#x27;</span>,<span class="string">&#x27;42&#x27;</span>,<span class="string">&#x27;43&#x27;</span>,<span class="string">&#x27;44&#x27;</span>,<span class="string">&#x27;45&#x27;</span>,<span class="string">&#x27;46&#x27;</span>,<span class="string">&#x27;47&#x27;</span>,<span class="string">&#x27;48&#x27;</span>,<span class="string">&#x27;49&#x27;</span>,<span class="string">&#x27;50&#x27;</span>,<span class="string">&#x27;51&#x27;</span>,<span class="string">&#x27;52&#x27;</span>,<span class="string">&#x27;53&#x27;</span>,<span class="string">&#x27;54&#x27;</span>,<span class="string">&#x27;55&#x27;</span>,<span class="string">&#x27;56&#x27;</span>,<span class="string">&#x27;57&#x27;</span>,</span><br><span class="line"><span class="string">&#x27;58&#x27;</span>,<span class="string">&#x27;59&#x27;</span>,<span class="string">&#x27;60&#x27;</span>,<span class="string">&#x27;61&#x27;</span>,<span class="string">&#x27;62&#x27;</span>,<span class="string">&#x27;63&#x27;</span>,<span class="string">&#x27;64&#x27;</span>,<span class="string">&#x27;65&#x27;</span>,<span class="string">&#x27;66&#x27;</span>,<span class="string">&#x27;67&#x27;</span>,<span class="string">&#x27;68&#x27;</span>,<span class="string">&#x27;69&#x27;</span>,<span class="string">&#x27;70&#x27;</span>,<span class="string">&#x27;71&#x27;</span>,<span class="string">&#x27;72&#x27;</span>,<span class="string">&#x27;73&#x27;</span>,<span class="string">&#x27;74&#x27;</span>,<span class="string">&#x27;75&#x27;</span>,<span class="string">&#x27;76&#x27;</span>,<span class="string">&#x27;77&#x27;</span>,</span><br><span class="line">&#x27;78&#x27;,&#x27;79&#x27;,&#x27;80&#x27;,&#x27;81&#x27;,&#x27;82&#x27;,&#x27;83&#x27;,&#x27;84&#x27;,&#x27;85&#x27;,&#x27;86&#x27;,&#x27;87&#x27;,&#x27;88&#x27;,&#x27;89&#x27;,&#x27;90&#x27;,&#x27;91&#x27;,&#x27;92&#x27;,&#x27;93&#x27;,&#x27;94&#x27;,&#x27;95&#x27;,&#x27;96&#x27;,&#x27;97&#x27;,&#x27;98&#x27;,&#x27;99&#x27;]&#125;</span><br></pre></td></tr></table></figure>
<p>campaigns表示表名，campaign表示列族名字。如果你不关注其他的信息，这就是你创建一个表所需要的。<br>那么剩下的是什么意思呢？容我一一道来。</p>
<h4 id="BLOCKCACHE"><a href="#BLOCKCACHE" class="headerlink" title="BLOCKCACHE"></a>BLOCKCACHE</h4><p>开启BLOCKCACHE，我们都知道使用Hbase读取数据的时候往往是一块一块的读的，那么可以从磁盘上一次性将所需要的容量读出来。所以BLOCKCACHE一般设置为读取的量。</p>
<h4 id="BLOOMFILTER"><a href="#BLOOMFILTER" class="headerlink" title="BLOOMFILTER"></a>BLOOMFILTER</h4><p>布隆过滤器，它说有不一定有，它说没有就一定没有。<br>使用一种数据结构来过滤大部分无效的读请求。</p>
<h4 id="SPLITS"><a href="#SPLITS" class="headerlink" title="SPLITS"></a>SPLITS</h4><p>预分区，Hbase是面向分布式设计的。但是往往会出现热点数据，出现的结果就是某台服务器读写被打爆，发挥不出分布式的优点。可以预先设计一些分区，来提前规避一些热点问题，也可以减少region分裂的时间。</p>
<h4 id="为什么列族只有一个"><a href="#为什么列族只有一个" class="headerlink" title="为什么列族只有一个"></a>为什么列族只有一个</h4><p>在一个Region中会有多个HStore，每个HStore对应一个Column Family。<br>HBase会在region下所有的StoreFile中最大的StoreFile大小超过阀值进行spliet。<br>而此时会出现一种情况，存在一大一小的HStore，而小的那个就被迫进行了spliet，导致查询小表的时候需要大量扫描，所有为的是对Column Family进行隔离。</p>
<p><a href="https://www.cnblogs.com/gaopeng527/p/4967186.html">https://www.cnblogs.com/gaopeng527/p/4967186.html</a></p>
<h3 id="查询"><a href="#查询" class="headerlink" title="查询"></a>查询</h3><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">put &quot;table&quot;,&quot;rowkey&quot;,&quot;columFamily:colum&quot;,&quot;value&quot;</span><br><span class="line"><span class="keyword">get</span> &quot;table&quot;,&quot;rowkey&quot;,&quot;columFamily:colum&quot;</span><br></pre></td></tr></table></figure>
<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">count &quot;campaigns&quot;</span><br><span class="line">scan &quot;campaigns&quot;, &#123;&#125;</span><br></pre></td></tr></table></figure>
<p>更多的请看：<a href="https://www.cnblogs.com/nexiyi/p/hbase_shell.html">https://www.cnblogs.com/nexiyi/p/hbase_shell.html</a></p>
<blockquote>
<p>有个小坑说下，使用truncate删除正表数据的时候，会将预分区都删除。所以还是最好drop，重新create。</p>
</blockquote>
<h2 id="最佳实践"><a href="#最佳实践" class="headerlink" title="最佳实践"></a>最佳实践</h2><p>最佳实践往往是踩坑过程中累计出来的。</p>
<h3 id="Phoenix"><a href="#Phoenix" class="headerlink" title="Phoenix"></a>Phoenix</h3><p>背景是这样的，业务部门使用的是Python来读取Hbase，然而直接使用ROWKEY无法做一些计算（可以使用Hbase coprossors），同时需要二级索引。然后调研了一下，发现了Phoenix这个“神器”，在Hbase上面再搭建一层SQL层，同时Phoenix自带了Hbase coprossors节约编写代码的时间，就决定是你了皮卡丘，然后不断踩坑.</p>
<h4 id="踩坑一：字符类型"><a href="#踩坑一：字符类型" class="headerlink" title="踩坑一：字符类型"></a>踩坑一：字符类型</h4><p>我们都知道在Mysql可以指定各种类型，有Integer、Bigdcimal。然而放入Hbase我们使用的是byte[] s= Bytes.toBytes(“r1”);</p>
<p>使用Phoenix指定类型之后就发现报错了，phoenix无法识别，phoenix是需要固定的字节长度来读取有类型的字段的。你可以使用<br><a href="https://github.com/apache/phoenix/blob/master/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java">https://github.com/apache/phoenix/blob/master/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java</a> 来放入的时候固定类型长度。或者select SUM(TO_NUMBER(“impressions”))  from “data_report_campaigns”，在读取的时候使用Phoenix提供的函数。</p>
<h4 id="踩坑二：二级索引"><a href="#踩坑二：二级索引" class="headerlink" title="踩坑二：二级索引"></a>踩坑二：二级索引</h4><p>原先单纯的以为二级索引和Mysql一样，然而发现是我们太过天真了。Phoenix的二级索引就是建立一个新的表，将建立索引的表作为ROWKEY，类似于倒排索引的概念。</p>
<img src="/index.png" width="100%" height="100%" alt="index"/>
然而蛋疼的是如果你在查询的时候有包含非索引列，那么他便不会走索引。

<p>另外，二级索引是Phoenix通过Hbase的coprossor生成的，所以只有通过phoenix才能会生成index数据。如果是通过Hbase来插入的数据，还需要在index表里面插数据。</p>
<h4 id="踩坑三：phoenix-4-7的bug"><a href="#踩坑三：phoenix-4-7的bug" class="headerlink" title="踩坑三：phoenix 4.7的bug"></a>踩坑三：phoenix 4.7的bug</h4><p>Hbase的数据数量和Phoenix的数据量对不上了，Hbase只有60W的数据，Phoenix发现有800W。还以为是高并发导致数据错乱，结果怎么试都没有复现。怀疑是和时间相关的bug，手动触发Hbase的Major compaction，果然复现了。</p>
<p>解决方案：delete from system.stats where physical_name=’CUST.PROFILE’;<br>连接：<a href="https://stackoverflow.com/questions/36873787/getting-inconsistent-row-count-from-phoenix-for-hbase">https://stackoverflow.com/questions/36873787/getting-inconsistent-row-count-from-phoenix-for-hbase</a></p>
<p>Hbase定期进行Major compaction之后，Phoenix并没有同步更新，所以需要删除数据。</p>
<h3 id="Hbase-coprossors-使用"><a href="#Hbase-coprossors-使用" class="headerlink" title="Hbase coprossors 使用"></a>Hbase coprossors 使用</h3><p>原本对于coprossors还是带有抵触心理，因为将程序放在数据源觉得总会对数据造成影响。后来发现包括TiDB以及其他针对大数据计算的框架，都是有相同的思考，将计算放在数据源。这样能够减少大数据传输的带宽限制，从而提升速度。coprossors分为两种：</p>
<ul>
<li>EndPoint 实现计算，类似存储过程</li>
<li>Observer 观察者模式，类似实现二级索引</li>
</ul>
<p>使用的Demo: <a href="https://www.ibm.com/developerworks/cn/opensource/os-cn-hbase-coprocessor1/index.html">https://www.ibm.com/developerworks/cn/opensource/os-cn-hbase-coprocessor1/index.html</a></p>
<h3 id="其他相关最佳实践"><a href="#其他相关最佳实践" class="headerlink" title="其他相关最佳实践"></a>其他相关最佳实践</h3><p><a href="https://www.cnblogs.com/davidwang456/articles/9253631.html">https://www.cnblogs.com/davidwang456/articles/9253631.html</a></p>
<h2 id="系统监控"><a href="#系统监控" class="headerlink" title="系统监控"></a>系统监控</h2><p>这里包括的Hbase的容灾、性能监控，以及系统如何平稳升级</p>
<h2 id="性能优化"><a href="#性能优化" class="headerlink" title="性能优化"></a>性能优化</h2><p>HDFS相关配置优化、HBase服务端优化（GC优化、Compaction优化、硬件配置优化）、列族设计优化、客户端优化</p>
<h2 id="整体理解"><a href="#整体理解" class="headerlink" title="整体理解"></a>整体理解</h2><p>对于系统监控和性能优化，没有一个很好的实践也给不出啥有效的信息。而通过学会使用和最佳实践之后，一定是理解系统设计的理念，包括整体的架构、数据结构。</p>
<p>简单的讲就是理解：</p>
<ul>
<li>一个Hbase的写过程是怎么样的？</li>
<li>一个Hbase的读过程是怎么样的？</li>
</ul>
<p>感觉需要讲的有点多，先放一个Hbase的整体架构图，剩下的容我慢慢来讲。<br><img src="/hbaseAll.png" width="100%" height="100%" alt="Hbase架构"/></p>

    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/blog/tags/Hbase/" rel="tag"># Hbase</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/blog/2018/11/14/2018/%E5%A6%82%E4%BD%95%E7%9B%91%E7%AE%A1%E5%A4%9A%E7%BA%BF%E7%A8%8B/" rel="prev" title="如何监管多线程">
      <i class="fa fa-chevron-left"></i> 如何监管多线程
    </a></div>
      <div class="post-nav-item">
    <a href="/blog/2018/12/01/2018/%E9%87%8D%E6%96%B0%E8%AE%A4%E8%AF%86%E6%97%A5%E5%BF%97%E7%B3%BB%E7%BB%9F/" rel="next" title="重新认识日志系统">
      重新认识日志系统 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  

  </div>


          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let activeClass = CONFIG.comments.activeClass;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          Table of Contents
        </li>
        <li class="sidebar-nav-overview">
          Overview
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%A6%82%E4%BD%95%E5%AD%A6%E4%B9%A0%E6%96%B0%E7%9A%84%E7%9F%A5%E8%AF%86"><span class="nav-number">1.</span> <span class="nav-text">如何学习新的知识</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AD%A6%E4%BC%9A%E4%BD%BF%E7%94%A8"><span class="nav-number">2.</span> <span class="nav-text">学会使用</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%88%9B%E5%BB%BAHbase%E8%A1%A8"><span class="nav-number">2.1.</span> <span class="nav-text">创建Hbase表</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#BLOCKCACHE"><span class="nav-number">2.1.1.</span> <span class="nav-text">BLOCKCACHE</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#BLOOMFILTER"><span class="nav-number">2.1.2.</span> <span class="nav-text">BLOOMFILTER</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#SPLITS"><span class="nav-number">2.1.3.</span> <span class="nav-text">SPLITS</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E4%B8%BA%E4%BB%80%E4%B9%88%E5%88%97%E6%97%8F%E5%8F%AA%E6%9C%89%E4%B8%80%E4%B8%AA"><span class="nav-number">2.1.4.</span> <span class="nav-text">为什么列族只有一个</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%9F%A5%E8%AF%A2"><span class="nav-number">2.2.</span> <span class="nav-text">查询</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%9C%80%E4%BD%B3%E5%AE%9E%E8%B7%B5"><span class="nav-number">3.</span> <span class="nav-text">最佳实践</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#Phoenix"><span class="nav-number">3.1.</span> <span class="nav-text">Phoenix</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#%E8%B8%A9%E5%9D%91%E4%B8%80%EF%BC%9A%E5%AD%97%E7%AC%A6%E7%B1%BB%E5%9E%8B"><span class="nav-number">3.1.1.</span> <span class="nav-text">踩坑一：字符类型</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E8%B8%A9%E5%9D%91%E4%BA%8C%EF%BC%9A%E4%BA%8C%E7%BA%A7%E7%B4%A2%E5%BC%95"><span class="nav-number">3.1.2.</span> <span class="nav-text">踩坑二：二级索引</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E8%B8%A9%E5%9D%91%E4%B8%89%EF%BC%9Aphoenix-4-7%E7%9A%84bug"><span class="nav-number">3.1.3.</span> <span class="nav-text">踩坑三：phoenix 4.7的bug</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Hbase-coprossors-%E4%BD%BF%E7%94%A8"><span class="nav-number">3.2.</span> <span class="nav-text">Hbase coprossors 使用</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%85%B6%E4%BB%96%E7%9B%B8%E5%85%B3%E6%9C%80%E4%BD%B3%E5%AE%9E%E8%B7%B5"><span class="nav-number">3.3.</span> <span class="nav-text">其他相关最佳实践</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%B3%BB%E7%BB%9F%E7%9B%91%E6%8E%A7"><span class="nav-number">4.</span> <span class="nav-text">系统监控</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96"><span class="nav-number">5.</span> <span class="nav-text">性能优化</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%95%B4%E4%BD%93%E7%90%86%E8%A7%A3"><span class="nav-number">6.</span> <span class="nav-text">整体理解</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">RunningEgg</p>
  <div class="site-description" itemprop="description">写下我的点点滴滴，写下我对这个世界的看法，还有我内心锁崇拜的技术</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/blog/archives/">
        
          <span class="site-state-item-count">89</span>
          <span class="site-state-item-name">posts</span>
        </a>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">24</span>
        <span class="site-state-item-name">tags</span>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="mailto:guodh_1@163.com" title="E-Mail → mailto:guodh_1@163.com" rel="noopener" target="_blank"><i class="fa fa-fw fa-envelope"></i>E-Mail</a>
      </span>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">RunningEgg</span>
</div>
  <div class="powered-by">Powered by <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> v5.3.0
  </div>
  <span class="post-meta-divider">|</span>
  <div class="theme-info">Theme – <a href="https://pisces.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Pisces</a> v7.7.1
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/blog/lib/anime.min.js"></script>
  <script src="/blog/lib/velocity/velocity.min.js"></script>
  <script src="/blog/lib/velocity/velocity.ui.min.js"></script>

<script src="/blog/js/utils.js"></script>

<script src="/blog/js/motion.js"></script>


<script src="/blog/js/schemes/pisces.js"></script>


<script src="/blog/js/next-boot.js"></script>




  















  

  

</body>
</html>
